<?php require_once('Connections/MYCONN.php'); ?>
<?php
if(isset($_GET["Tbl"]) && isset($_GET["CName"] ) && isset($_GET["ID"]) && isset($_GET["Value"]) && isset($_GET["look"]) )
{
	if(isset($_GET["Tbl"]) && $_GET["Tbl"] != "")
	{
		$TblName = $_GET["Tbl"];
	}
	if(isset($_GET["ID"]) && $_GET["ID"] != "")
	{
		$ParentID = $_GET["ID"];
	}
	if(isset($_GET["CName"]) && $_GET["CName"] != "")
	{
		$CName = $_GET["CName"];
	}
	if(isset($_GET["Value"]) && $_GET["Value"] != "")
	{
		$Value = $_GET["Value"];
	}
	if(isset($_GET["look"]) && $_GET["look"] != "")
	{
		$look = $_GET["look"];
	}
	$TblName = base64_decode($TblName);
	$ParentID = base64_decode($ParentID);
	$CName = base64_decode($CName);
	$look = base64_decode($look);


	$sSQL ="SELECT ParentID FROM tb_activity WHERE ParentID=".$ParentID." AND LookupID=".$LookupID." ";
	mysql_select_db($database_MYCONN, $MYCONN);
	$Result1 = mysql_query($sSQL, $MYCONN) or die(mysql_error());
	$totalRows1 = mysql_num_rows($Result1);
	
		if($totalRows1>0){
			if($CName=="Description"){
				$sSQL2 ="UPDATE tb_activity SET ".$CName." = '".$Value."' WHERE ParentID=".$ParentID." AND LookupID=".$look."";
			}
			else{
				$sSQL2 ="UPDATE tb_activity SET ".$CName." = ".$Value." WHERE ParentID=".$ParentID." AND LookupID=".$look."";
		
			}
		}
		else{
			if($CName=="Description"){
				$sSQL2 ="INSERT INTO tb_activity (".$CName.", ParentID, LookupID) VALUES ('".$Value."', ".$ParentID.", ".$look.")";
			}
			else{
				$sSQL2 ="INSERT INTO tb_activity (".$CName.", ParentID, LookupID) VALUES (".$Value.", ".$ParentID.", ".$look.")";
		
			}
		}
		
		//echo "alert('".$sSQL."');";

		//mysql_select_db($database_MYCONN, $MYCONN);
		$Result2 = mysql_query($sSQL2, $MYCONN) or die(mysql_error());
		$totalRows2 = mysql_num_rows($Result2);

		echo $Result2; 

}
else
{
echo "ERROR : Parameters !!!";
}

?>